<template>
	<view class="content">
		<view class="btn-warp">
			<view @click="jump_train" v-if="connect==true">
				<bigBtn 
				:btnBoxWidth="btnBoxWidthX" 
				:btnBoxHeight="btnBoxHeightX" 
				:btnColor="btnColorX"
				:btnImgSrc="btnImgSrcX" 
				:btnText="btnTextX" 
				:btnTextColor="btnTextColorX"
				:btnTextSize="btnTextSizeX" 
				:btnImgWidth="btnImgWidthX" 
				:btnRadius="btnRadiusX" btnEColor="#FF6B3E"
					btnFColor="#FA709A" warpBorderColor="#FA90A3">
				</bigBtn>
			</view>
			<view @click="jump_blue" v-else>
				<bigBtn 
				:btnBoxWidth="btnBoxWidthB" 
				:btnBoxHeight="btnBoxHeightB" 
				:btnColor="btnColorB"
				:btnImgSrc="btnImgSrcB" 
				:btnText="btnTextB" 
				:btnTextColor="btnTextColorB"
				:btnTextSize="btnTextSizeB" 
				:btnImgWidth="btnImgWidthB" 
				:btnRadius="btnRadiusB" btnEColor="#969696"
					btnFColor="#B4B4B4" warpBorderColor="#B3B3B3">
				</bigBtn>
			</view>
			<view class="btn-box">
				<view class="btn" style="width:600rpx;height:200rpx;borderRadius:20rpx;" @click="jump">
					<view class="btn-img">
						<image :src="btnImgSrc" mode="aspectFit" style="width: 100rpx;height:100rpx;"></image>
					</view>
					<view class="btn-text"><text style="color:#FFFFFF;fontSize:20px;">修改健康信息</text></view>
				</view>
				<view class="btn btn-img1" style="width:600rpx;height:200rpx;borderRadius:20rpx;" @click="jump_history">
					<view>
						<image :src="btnImgSrcH" mode="aspectFit" style="width: 100rpx;height:100rpx;"></image>
					</view>
					<view class="btn-text"><text style="color:#FFFFFF;fontSize:20px;">历史训练数据</text></view>
				</view>
			</view>
		</view>
		<!-- <u-modal v-model="show" :content="content" :title="title" @confirm="jump_blue"></u-modal> -->
		<!-- <view @click="jump1">提交1</view> -->
	</view>
</template>

<script>
	import bigBtnL from '@/components/bigButtonLeft.vue';
	import bigBtn from '@/components/bigButton.vue';
	export default {
		components: {
			bigBtnL,
			bigBtn
		},
		data() {
			return {
				btnBoxWidthB: 400,
				btnBoxHeightB: 400,
				btnColorB: "#A5A5A5",
				btnImgSrcB: "../../../static/icon/training/blueTooth.png",
				btnTextB: "蓝牙未连接",
				btnTextColorB: "#ffffff",
				btnTextSizeB: 25,
				btnImgWidthB: 180,
				btnRadiusB: 200,

				btnBoxWidthX: 400,
				btnBoxHeightX: 400,
				btnColorX: "#FA7097",
				btnImgSrcX: "../../../static/icon/training/train.png",
				btnTextX: "开始训练",
				btnTextColorX: "#ffffff",
				btnTextSizeX: 25,
				btnImgWidthX: 180,
				btnRadiusX: 200,

				btnBoxWidth: 600,
				btnBoxHeight: 200,
				btnFColor: "#74B4FC",
				btnEColor: "#5D93FF",
				btnImgSrc: "../../../static/icon/training/editHealth.png",
				btnText: "修改我的健康信息",
				btnTextColor: "#ffffff",
				btnTextSize: 20,
				btnImgWidth: 100,
				btnRadius: 10,

				btnBoxWidthH: 600,
				btnBoxHeightH: 200,
				btnFColorH: "#53D7AD",
				btnEColorH: "#40B9D7",
				btnImgSrcH: "../../../static/icon/training/historyData.png",
				btnTextH: "历史训练数据  ",
				btnTextColorH: "#ffffff",
				btnTextSizeH: 20,
				btnImgWidthH: 100,
				btnRadiusH: 10,

				show: false,
				content: '请打开手机蓝牙，连接康复设备',
				title: "蓝牙未连接",

				connect: false,
				// connect: true
				

			}
		},
		onLoad() {
			this.connect = uni.getStorageSync("connectBlue");
		},
		onShow() {
			this.connect = uni.getStorageSync("connectBlue");
		},
		// 扫一扫
		onNavigationBarButtonTap() {
			uni.scanCode({
				success: (res) => {
					console.log('条码类型：' + res.scanType);
					console.log('条码内容：' + res.result);
					// uni.showToast({
					// 	title: `${res.result}`
					// })
					const usertoken = uni.getStorageSync("usertoken");
					const acc = uni.getStorageSync("accountInfo")
					const parms = {
						phoneNum: acc.phone,
						qrContent: res.result
					}
					uni.request({
						url: this.serverUrl + '/user/QRbind',
						data: parms,
						method: "POST",
						header: {
							"usertoken": usertoken
						},
						success: (res) => {
							console.log(res.data)
							if (res.data.status == 200) {
								uni.showToast({
									duration: 800,
									title: '提交成功'
								})
							}
						},
						fail: (err) => {
							console.log('err', err);
						}
					})
				}
			});
		},
		methods: {
			jump1() {
				uni.navigateTo({
					url: '../../training/isTraining/isTraining'
				})
			},
			open() {
				this.show = true;
				// this.connect = true;
			},
			jump_blue() {
				uni.navigateTo({
					url: '../../blue-tooth/blue-tooth'
				})
			},
			submit() {
				uni.navigateTo({
					url: '../../blue-tooth/blue-tooth'
				})
			},
			jump_history() {
				uni.navigateTo({
					url: '../../training/history-train-data/history-train-data'
				})
			},
			jump_train() {
				console.log(123);
				uni.navigateTo({
					// url: '../../training/isTraining/isTraining',
					url: '../../training/isTraining/jumpGame'
				})
			},
			jump() {
				uni.navigateTo({
					url: '../../my_module/health/info-date/info-date'
				})
			}
		}
	}
</script>

<style>
	@import url("training.css");
</style>
